//
//  AddBabyInformationViewController.m
//  TryShopping
//
//  Created by panquanReabam.com on 16/6/29.
//  Copyright © 2016年 RuiBen. All rights reserved.
//
#import "AddBabyInformationViewController.h"
#import "ZJSwitch.h"
@interface AddBabyInformationViewController ()<MBProgressHUDDelegate,UIGestureRecognizerDelegate,UINavigationControllerDelegate,UITextFieldDelegate,UISearchBarDelegate>
@property(nonatomic,retain)UIDatePicker* da3;
@property(nonatomic,retain)UIDatePicker* da1;
@property(nonatomic,retain)UIDatePicker* da2;
@property(nonatomic,strong)NSString* sex1;
@property(nonatomic,strong)NSString* sex2;
@property(nonatomic,strong)NSString* sex3;
@property(nonatomic,strong)NSString* place1;
@property(nonatomic,strong)NSString* place2;
@property(nonatomic,strong)NSString* place3;
@property(nonatomic,strong)NSString* mbId1;
@property(nonatomic,strong)NSString* mbId2;
@property(nonatomic,strong)NSString* mbId3;
@end

@implementation AddBabyInformationViewController
{
    UIView*myToolBar;
    
}
//@synthesize alt = alt;
-(void)BackAction:(UIButton *)sender{
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
    self.navigationController.delegate = nil;
    
}
- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        self.navigationController.interactivePopGestureRecognizer.enabled = NO;
    }
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [[self rdv_tabBarController] setTabBarHidden:YES];
    self.navigationController.navigationBarHidden=NO;
    self.navigationController.navigationBar.barStyle = UIBaselineAdjustmentNone;
    UILabel *lineLabel=[[UILabel alloc] initWithFrame:CGRectMake(0, 43,ScreenWidth, 1)];
    [lineLabel setBackgroundColor:[UIColor colorWithRed:238.0/255.0 green:238.0/255.0 blue:238.0/255.0 alpha:1.0]];
    [self.navigationController.navigationBar addSubview:lineLabel];
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
    [[UINavigationBar appearance] setBarTintColor:Color];
    
    UIImage* backImage = [UIImage imageNamed:@"fanhui"];
    CGRect backframe = CGRectMake(0,0,30,30);
    UIButton* backButton= [[UIButton alloc] initWithFrame:backframe];
    [backButton setBackgroundImage:backImage forState:UIControlStateNormal];
    backButton.titleLabel.textAlignment=NSTextAlignmentLeft;
    [backButton addTarget:self action:@selector(BackAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem* leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    self.navigationItem.leftBarButtonItem = leftBarButtonItem;
    self.navigationController.delegate = self;
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@""] forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.shadowImage =[[UIImage alloc] init];
    self.title=@"宝宝信息";
    
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                                     [UIColor blackColor],
                                                                     UITextAttributeTextColor,
                                                                     [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1],
                                                                     UITextAttributeTextShadowColor,
                                                                     [NSValue valueWithUIOffset:UIOffsetMake(0, 0)],
                                                                     UITextAttributeTextShadowOffset,
                                                                     [UIFont fontWithName:@"Helvetica Neue" size:tetlefot],
                                                                     UITextAttributeFont,nil]];
    
    
    UIButton*editor = [[UIButton alloc] initWithFrame:CGRectMake(30, 0.0, 35, 35)];
    [editor setTitle:@"保存" forState:UIControlStateNormal];
    editor.titleLabel.font=[UIFont systemFontOfSize:16];
    [editor setTitleColor:luseColor forState:UIControlStateNormal];
    [editor addTarget:self action:@selector(baocun:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem* myBtnBtn = [[UIBarButtonItem alloc] initWithCustomView:editor];
    self.navigationItem.rightBarButtonItem = myBtnBtn;
    
    
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor=zuiqianhuiColor;
    [self setAutoLayout];
    myToolBar=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, viewheight)];
    myToolBar.backgroundColor=jianpancolor;
    UIButton*  tubtnDone=[[UIButton alloc]initWithFrame:CGRectMake(logoX,logoY, logoheight, logowidth)];
    [tubtnDone setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [tubtnDone addTarget:self action:@selector(OnTapDone) forControlEvents:UIControlEventTouchUpInside];
    [myToolBar addSubview:tubtnDone];
    UIButton*btnDone111=[[UIButton alloc]initWithFrame:CGRectMake(myToolBar.frame.size.width - 55, 12, 40, 16)];
    [btnDone111 setTitle:@"确定" forState:UIControlStateNormal];
    [btnDone111 setTitleColor:jianpancolor1 forState:UIControlStateNormal];
    btnDone111 .titleLabel .font=[UIFont systemFontOfSize:keyboardFot];
    [btnDone111 addTarget:self action:@selector(OnTapDone) forControlEvents:UIControlEventTouchUpInside];
    [myToolBar addSubview:btnDone111];
    myToolBar.alpha=alp;
    UIButton* dabtn=[[UIButton alloc]initWithFrame:CGRectMake(myToolBar.frame.size.width-60, 0, 60, 40)];
    [dabtn addTarget:self action:@selector(OnTapDone) forControlEvents:UIControlEventTouchUpInside];
    [myToolBar addSubview:dabtn];
    
    _jianBtn1.userInteractionEnabled=NO;
    _jianBtn2.userInteractionEnabled=NO;
    _jianBtn3.userInteractionEnabled=NO;
    _da3 = [[UIDatePicker alloc] init];
    [_da3 addTarget:self action:@selector(dateChanged3:) forControlEvents:UIControlEventValueChanged];
    _da3.datePickerMode = UIDatePickerModeDate;
    _da3.backgroundColor=[UIColor whiteColor];
    _da1 = [[UIDatePicker alloc] init];
    _da2 = [[UIDatePicker alloc] init];
    [_da2 addTarget:self action:@selector(dateChanged2:) forControlEvents:UIControlEventValueChanged];
    _da2.datePickerMode = UIDatePickerModeDate;
    _da2.backgroundColor=[UIColor whiteColor];
    [_da1 addTarget:self action:@selector(dateChanged1:) forControlEvents:UIControlEventValueChanged];
    _da1.datePickerMode = UIDatePickerModeDate;
    _da1.backgroundColor=[UIColor whiteColor];
    
    [_jianBtn1 setImage:[UIImage imageNamed:@"zhankai"] forState:UIControlStateNormal];
    [_jianBtn3 setImage:[UIImage imageNamed:@"zhankai"] forState:UIControlStateNormal];
    [_jianBtn2 setImage:[UIImage imageNamed:@"zhankai"] forState:UIControlStateNormal];
    for (int i=0; i<self.babys.count; i++) {
        
        if (i==0) {
            _theOneBabyNameText.text=[self.babys[0]objectForKey:@"name"];
            self.sex1=[self.babys[0]objectForKey:@"sex"];
            _theOneBabyDateText.text=[self.babys[0]objectForKey:@"birthDate"];
            self.mbId1=[self.babys[0]objectForKey:@"mbId"];
            if (_theOneBabyDateText.text ==NULL||[_theOneBabyDateText.text isEqualToString:@""]) {
                
            }else{
                 _da1.date =[self dateFromString:_theOneBabyDateText.text ];
            }
        }else if (i==1){
            _theTwoBabyNameText.text=[self.babys[1]objectForKey:@"name"];
            self.sex2=[self.babys[1]objectForKey:@"sex"];
            _theTwoBabyDateText.text=[self.babys[1]objectForKey:@"birthDate"];
            self.mbId2=[self.babys[1]objectForKey:@"mbId"];
           
              if ( _theTwoBabyDateText.text==NULL||[_theTwoBabyDateText.text isEqualToString:@""]) {
            }else{
                _da2.date =[self dateFromString:_theTwoBabyDateText.text ];
            }
            
        }else if (i==2){
            _theThreeBabyNameText.text=[self.babys[2]objectForKey:@"name"];
            self.sex3=[self.babys[2]objectForKey:@"sex"];
            _theThreeBabyDateText.text=[self.babys[2]objectForKey:@"birthDate"];
            self.mbId3=[self.babys[2]objectForKey:@"mbId"];
        
              if (_theThreeBabyDateText.text ==NULL||[_theThreeBabyDateText.text isEqualToString:@""]) {
            }else{
                _da3.date =[self dateFromString:_theThreeBabyDateText.text];}
        }
        
    }
    
    _theOneBabyDateText.inputView = _da1;
    _theTwoBabyDateText.inputView = _da2;
    _theThreeBabyDateText.inputView = _da3;
    _theOneBabyDateText.inputAccessoryView= myToolBar;
    _theTwoBabyDateText.inputAccessoryView= myToolBar;
    _theThreeBabyDateText.inputAccessoryView= myToolBar;
    _theOneBabyNameText.inputAccessoryView= myToolBar;
    _theTwoBabyNameText.inputAccessoryView= myToolBar;
    _theThreeBabyNameText.inputAccessoryView= myToolBar;
    
    self.place1=@"1";
    self.place2=@"2";
    self.place3=@"3";
    ZJSwitch *switch1 = [[ZJSwitch alloc] initWithFrame:CGRectMake(ScreenWidth-70, 55, 50, 25)];
    switch1.onText = @"男";
    switch1.offText = @"女";
    if (![self.sex1 isEqual:[NSNull null]]) {
        if ([self.sex1 isEqualToString:@"男"]) {
            switch1.on = YES;
            switch1.backgroundColor = [UIColor clearColor];
            switch1.onTintColor = [UIColor colorWithRed:53/255.0 green:159/255.0 blue:234/255.0 alpha:1];
            switch1.tintColor = [UIColor colorWithRed:253.00/255.0 green:129.00/255.0 blue:182.00/255.0 alpha:1];
            self.sex1= @"男";
            
        }else {
            switch1.on = NO;
            switch1.backgroundColor = [UIColor clearColor];
            switch1.onTintColor = [UIColor colorWithRed:53/255.0 green:159/255.0 blue:234/255.0 alpha:1];
            switch1.tintColor = [UIColor colorWithRed:253.00/255.0 green:129.00/255.0 blue:182.00/255.0 alpha:1];
            self.sex1= @"女";
        }
    }else {
        switch1.on = NO;
        switch1.backgroundColor = [UIColor clearColor];
        switch1.onTintColor = [UIColor colorWithRed:53/255.0 green:159/255.0 blue:234/255.0 alpha:1];
        switch1.tintColor = [UIColor colorWithRed:253.00/255.0 green:129.00/255.0 blue:182.00/255.0 alpha:1];
        self.sex1= @"女";
        
    }
    [switch1 addTarget:self action:@selector(switchAction1:) forControlEvents:UIControlEventValueChanged];
    [_theOneBabyView addSubview:switch1];
    
    
    ZJSwitch *switch2 = [[ZJSwitch alloc] initWithFrame:CGRectMake(ScreenWidth-70, 55, 50, 25)];
    switch2.onText = @"男";
    switch2.offText = @"女";
    if (![self.sex2 isEqual:[NSNull null]]) {
        if ([self.sex2 isEqualToString:@"男"]) {
            switch2.on = YES;
            switch2.backgroundColor = [UIColor clearColor];
            switch2.onTintColor = [UIColor colorWithRed:53/255.0 green:159/255.0 blue:234/255.0 alpha:1];
            switch2.tintColor = [UIColor colorWithRed:253.00/255.0 green:129.00/255.0 blue:182.00/255.0 alpha:1];
            self.sex2= @"男";
            
        }else {
            switch2.on = NO;
            switch2.backgroundColor = [UIColor clearColor];
            switch2.onTintColor = [UIColor colorWithRed:53/255.0 green:159/255.0 blue:234/255.0 alpha:1];
            switch2.tintColor = [UIColor colorWithRed:253.00/255.0 green:129.00/255.0 blue:182.00/255.0 alpha:1];
            self.sex2= @"女";
        }
    }else {
        switch2.on = NO;
        switch2.backgroundColor = [UIColor clearColor];
        switch2.onTintColor = [UIColor colorWithRed:53/255.0 green:159/255.0 blue:234/255.0 alpha:1];
        switch2.tintColor = [UIColor colorWithRed:253.00/255.0 green:129.00/255.0 blue:182.00/255.0 alpha:1];
        self.sex2= @"女";
        
    }
    [switch2 addTarget:self action:@selector(switchAction2:) forControlEvents:UIControlEventValueChanged];
    [_theTwoBabyView addSubview:switch2];
    
    ZJSwitch *switch3 = [[ZJSwitch alloc] initWithFrame:CGRectMake(ScreenWidth-70, 55, 50, 25)];
    switch3.onText = @"男";
    switch3.offText = @"女";
    if (![self.sex3 isEqual:[NSNull null]]) {
        if ([self.sex3 isEqualToString:@"男"]) {
            switch3.on = YES;
            switch3.backgroundColor = [UIColor clearColor];
            switch3.onTintColor = [UIColor colorWithRed:53/255.0 green:159/255.0 blue:234/255.0 alpha:1];
            switch3.tintColor = [UIColor colorWithRed:253.00/255.0 green:129.00/255.0 blue:182.00/255.0 alpha:1];
            self.sex3= @"男";
            
        }else {
            switch3.on = NO;
            switch3.backgroundColor = [UIColor clearColor];
            switch3.onTintColor = [UIColor colorWithRed:53/255.0 green:159/255.0 blue:234/255.0 alpha:1];
            switch3.tintColor = [UIColor colorWithRed:253.00/255.0 green:129.00/255.0 blue:182.00/255.0 alpha:1];
            self.sex3= @"女";
        }
    }else {
        switch3.on = NO;
        switch3.backgroundColor = [UIColor clearColor];
        switch3.onTintColor = [UIColor colorWithRed:53/255.0 green:159/255.0 blue:234/255.0 alpha:1];
        switch3.tintColor = [UIColor colorWithRed:253.00/255.0 green:129.00/255.0 blue:182.00/255.0 alpha:1];
        self.sex3= @"女";
        
    }
    [switch3 addTarget:self action:@selector(switchAction3:) forControlEvents:UIControlEventValueChanged];
    [_theThreeBabyView addSubview:switch3];
    
    
    
    _theOneBabyView.layer.borderWidth = 0.40;
    _theOneBabyView.layer.borderColor = qianhuiColor.CGColor;
    _theTwoBabyView.layer.borderWidth = 0.40;
    _theTwoBabyView.layer.borderColor = qianhuiColor.CGColor;
    _theThreeBabyView.layer.borderWidth = 0.40;
    _theThreeBabyView.layer.borderColor = qianhuiColor.CGColor;
    UILabel*lineLabel=[[UILabel alloc]initWithFrame:CGRectMake(10, 44, ScreenWidth-20, 0.40)];
    lineLabel.backgroundColor=qianhuiColor;
    [_theOneBabyView addSubview:lineLabel];
    UILabel*lineLabel1=[[UILabel alloc]initWithFrame:CGRectMake(10, 44*2, ScreenWidth-20, 0.40)];
    lineLabel1.backgroundColor=qianhuiColor;
    [_theOneBabyView addSubview:lineLabel1];
    UILabel*lineLabel2=[[UILabel alloc]initWithFrame:CGRectMake(10, 44, ScreenWidth-20, 0.40)];
    lineLabel2.backgroundColor=qianhuiColor;
    [_theTwoBabyView addSubview:lineLabel2];
    UILabel*lineLabel3=[[UILabel alloc]initWithFrame:CGRectMake(10, 44*2, ScreenWidth-20, 0.40)];
    lineLabel3.backgroundColor=qianhuiColor;
    [_theTwoBabyView addSubview:lineLabel3];
    UILabel*lineLabel4=[[UILabel alloc]initWithFrame:CGRectMake(10, 44, ScreenWidth-20, 0.40)];
    lineLabel4.backgroundColor=qianhuiColor;
    [_theThreeBabyView addSubview:lineLabel4];
    UILabel*lineLabel5=[[UILabel alloc]initWithFrame:CGRectMake(10, 44*2, ScreenWidth-20, 0.40)];
    lineLabel5.backgroundColor=qianhuiColor;
    [_theThreeBabyView addSubview:lineLabel5];
}
-(void)switchAction1:(UISwitch*)sender{
    
    if (sender.on ==YES) {
        
        self.sex1=@"男";
    }
    if (sender.on == NO) {
        
        self.sex1=@"女";
    }
}

-(void)switchAction2:(UISwitch*)sender{
    
    if (sender.on ==YES) {
        
        self.sex2=@"男";
    }
    if (sender.on == NO) {
        
        self.sex2=@"女";
    }
}

-(void)switchAction3:(UISwitch*)sender{
    
    if (sender.on ==YES) {
        
        self.sex3=@"男";
    }
    if (sender.on == NO) {
        
        self.sex3=@"女";
    }
}

-(void)baocun:(UIButton*)sender{
    
    NSMutableArray *mDocumentLine=[NSMutableArray array];
    NSMutableDictionary *dic1 = [NSMutableDictionary dictionary];
    [dic1 setValue:self.sex1 forKey:@"sex"];
    [dic1 setValue:self.mbId1 forKey:@"mbId"];
    [dic1 setValue:_theOneBabyNameText.text forKey:@"name"];
    [dic1 setValue:_theOneBabyDateText.text forKey:@"birthDate"];
    [dic1 setValue:self.place1 forKey:@"place"];
    [mDocumentLine addObject:dic1];
    NSMutableDictionary *dic2 = [NSMutableDictionary dictionary];
    [dic2 setValue:self.sex2 forKey:@"sex"];
    [dic2 setValue:self.mbId2 forKey:@"mbId"];
    [dic2 setValue:_theTwoBabyNameText.text forKey:@"name"];
    [dic2 setValue:_theTwoBabyDateText.text forKey:@"birthDate"];
    [dic2 setValue:self.place2 forKey:@"place"];
    [mDocumentLine addObject:dic2];
    
    NSMutableDictionary *dic3 = [NSMutableDictionary dictionary];
    [dic3 setValue:self.sex3 forKey:@"sex"];
    [dic3 setValue:self.mbId3 forKey:@"mbId"];
    [dic3 setValue:_theThreeBabyNameText.text forKey:@"name"];
    [dic3 setValue:_theThreeBabyDateText.text forKey:@"birthDate"];
    [dic3 setValue:self.place3 forKey:@"place"];
    [mDocumentLine addObject:dic3];
    
    NSLog(@"-------%@",mDocumentLine);
    
    [_delegate secondViewController:self babys:mDocumentLine];
    [self.navigationController popViewControllerAnimated:YES];
    
}
-(void)dateChanged2:(UIButton*)sender{
    UIDatePicker* picker = (UIDatePicker*)sender;
    NSDateFormatter* df = [[NSDateFormatter alloc] init];
    [df setDateFormat:@"yyyy-MM-dd"];
    if ([_theTwoBabyDateText isFirstResponder])
    {
        _theTwoBabyDateText.text = [NSString stringWithFormat:@"%@", [df stringFromDate:picker.date]];
        
    }else{
        
        _theTwoBabyDateText.text = [NSString stringWithFormat:@"%@", [df stringFromDate:picker.date]];
    }
}
-(void)dateChanged3:(UIButton*)sender{
    UIDatePicker* picker = (UIDatePicker*)sender;
    NSDateFormatter* df = [[NSDateFormatter alloc] init];
    [df setDateFormat:@"yyyy-MM-dd"];
    if ([_theThreeBabyDateText isFirstResponder])
    {
        _theThreeBabyDateText.text = [NSString stringWithFormat:@"%@", [df stringFromDate:picker.date]];
        
    }else{
        
        _theThreeBabyDateText.text = [NSString stringWithFormat:@"%@", [df stringFromDate:picker.date]];
    }
}

-(void)dateChanged1:(UIButton*)sender{
    UIDatePicker* picker = (UIDatePicker*)sender;
    NSDateFormatter* df = [[NSDateFormatter alloc] init];
    [df setDateFormat:@"yyyy-MM-dd"];
    if ([_theOneBabyDateText isFirstResponder])
    {
        _theOneBabyDateText.text = [NSString stringWithFormat:@"%@", [df stringFromDate:picker.date]];
        
    }else{
        
        _theOneBabyDateText.text = [NSString stringWithFormat:@"%@", [df stringFromDate:picker.date]];
    }
}


- (void)textFieldDidBeginEditing:(UITextField *)textField{
    if (textField.tag==3) {
        
        [_jianBtn3 setImage:[UIImage imageNamed:@"shouqi_shang"] forState:UIControlStateNormal];
        [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
        self.view.frame =CGRectMake(0, -160, ScreenWidth, ScreenHeight);
        [UIView commitAnimations];
       
    }if (textField.tag==2) {
        [_jianBtn2 setImage:[UIImage imageNamed:@"shouqi_shang"] forState:UIControlStateNormal];

        [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
        self.view.frame =CGRectMake(0, -50, ScreenWidth, ScreenHeight);
        [UIView commitAnimations];
    
    }
    else
    if (textField.tag==1) {
            
        [_jianBtn1 setImage:[UIImage imageNamed:@"shouqi_shang"] forState:UIControlStateNormal];
 
        }
    
}
- (BOOL)textFieldShouldClear:(UITextField *)textField{


    
    return YES;
}

- (void)textFieldDidEndEditing:(UITextField *)textField{
    
    
    if (textField.tag==3) {
        
        if (textField.text.length<1) {
            NSDateFormatter* df = [[NSDateFormatter alloc] init];
            [df setDateFormat:@"yyyy-MM-dd"];
            _theThreeBabyDateText.text = [NSString stringWithFormat:@"%@", [df stringFromDate:[NSDate date]]];
        }
    }else
        if (textField.tag==2) {
            
            if (textField.text.length<1) {
                NSDateFormatter* df = [[NSDateFormatter alloc] init];
                [df setDateFormat:@"yyyy-MM-dd"];
                _theTwoBabyDateText.text = [NSString stringWithFormat:@"%@", [df stringFromDate:[NSDate date]]];
                
            }
        }
        else
            if (textField.tag==1) {
                
                if (textField.text.length<1) {
                    NSDateFormatter* df = [[NSDateFormatter alloc] init];
                    [df setDateFormat:@"yyyy-MM-dd"];
                    _theOneBabyDateText.text = [NSString stringWithFormat:@"%@", [df stringFromDate:[NSDate date]]];
                }
            }
}
-(void)OnTapDone{
     [_jianBtn1 setImage:[UIImage imageNamed:@"zhankai"] forState:UIControlStateNormal];
     [_jianBtn3 setImage:[UIImage imageNamed:@"zhankai"] forState:UIControlStateNormal];
     [_jianBtn2 setImage:[UIImage imageNamed:@"zhankai"] forState:UIControlStateNormal];
    [_theOneBabyDateText resignFirstResponder];
    [_theTwoBabyDateText resignFirstResponder];
    [_theThreeBabyDateText resignFirstResponder];
    [_theOneBabyNameText resignFirstResponder];
    [_theTwoBabyNameText resignFirstResponder];
    [_theThreeBabyNameText resignFirstResponder];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
    self.view.frame =CGRectMake(0, 0, ScreenWidth, ScreenHeight);
    [UIView commitAnimations];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}
-(void)setAutoLayout
{
    [_theOneBabyView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view.mas_left);
        make.right.equalTo(self.view.mas_right);
        make.top.equalTo(self.view.mas_top).with.offset(10+64);
        make.height.equalTo(@132);
    }];
    [_theTwoBabyView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view.mas_left);
        make.right.equalTo(self.view.mas_right);
        make.top.equalTo(_theOneBabyView.mas_bottom).with.offset(10);
        make.height.equalTo(@132);
    }];
    [_theThreeBabyView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view.mas_left);
        make.right.equalTo(self.view.mas_right);
        make.top.equalTo(_theTwoBabyView.mas_bottom).with.offset(10);
        make.height.equalTo(@132);
    }];
    [_theOneBabyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_theOneBabyView.mas_left).with.offset(15) ;
        make.right.equalTo(_theOneBabyView.mas_right) ;
        make.height.equalTo(@44) ;
        make.top.equalTo(_theOneBabyView.mas_top).with.offset(0);
    }];
    
    [_theOneBabyNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_theOneBabyView.mas_left).with.offset(15) ;
        make.height.equalTo(@44) ;
        make.top.equalTo(_theOneBabyView.mas_top).with.offset(44);
    }];
    [_theOneBabyNameText mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_theOneBabyNameLabel.mas_right).with.offset(10) ;
        make.width.equalTo(@150) ;
        make.height.equalTo(@44) ;
        make.top.equalTo(_theOneBabyLabel.mas_bottom).with.offset(0);
    }];
    [_theOneDateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_theOneBabyView.mas_left).with.offset(15) ;
        make.height.equalTo(@44);
        make.top.equalTo(_theOneBabyView.mas_top).with.offset(88);
    }];
    [_theOneBabyDateText mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_theOneDateLabel.mas_right).with.offset(10) ;
        make.right.equalTo(_theOneBabyView.mas_right) ;
        make.height.equalTo(@44) ;
        make.top.equalTo(_theOneBabyNameLabel.mas_top).with.offset(44);
    }];
    
    [_jianBtn1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(_theOneBabyView.mas_right).with.offset(-10) ;
        make.height.equalTo(@33) ;
        make.width.equalTo(@33) ;
        make.centerY.equalTo(_theOneBabyDateText.mas_centerY);
    }];
    
    [_theTwoBabyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_theTwoBabyView.mas_left).with.offset(15) ;
        make.right.equalTo(_theTwoBabyView.mas_right) ;
        make.height.equalTo(@44) ;
        make.top.equalTo(_theTwoBabyView.mas_top).with.offset(0);
    }];
    
    [_theTwoBabyNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_theTwoBabyView.mas_left).with.offset(15) ;
        make.height.equalTo(@44) ;
        make.top.equalTo(_theTwoBabyView.mas_top).with.offset(44);
    }];
    [_theTwoBabyNameText mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_theTwoBabyNameLabel.mas_right).with.offset(10) ;
        make.width.equalTo(@150) ;
        make.height.equalTo(@44) ;
        make.top.equalTo(_theTwoBabyLabel.mas_bottom).with.offset(0);
    }];
    [_theTwoDateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_theTwoBabyView.mas_left).with.offset(15) ;
        make.height.equalTo(@44);
        make.top.equalTo(_theTwoBabyView.mas_top).with.offset(88);
    }];
    [_theTwoBabyDateText mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_theTwoDateLabel.mas_right).with.offset(10) ;
        make.right.equalTo(_theTwoBabyView.mas_right) ;
        make.height.equalTo(@44) ;
        make.top.equalTo(_theTwoBabyNameLabel.mas_top).with.offset(44);
    }];
    
    [_jianBtn2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(_theTwoBabyView.mas_right).with.offset(-10) ;
        make.height.equalTo(@33) ;
        make.width.equalTo(@33) ;
        make.centerY.equalTo(_theTwoBabyDateText.mas_centerY);
    }];
    
    [_theThreeBabyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_theThreeBabyView.mas_left).with.offset(15) ;
        make.right.equalTo(_theThreeBabyView.mas_right) ;
        make.height.equalTo(@44) ;
        make.top.equalTo(_theThreeBabyView.mas_top).with.offset(0);
    }];
    
    [_theThreeBabyNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_theThreeBabyView.mas_left).with.offset(15) ;
        make.height.equalTo(@44) ;
        make.top.equalTo(_theThreeBabyView.mas_top).with.offset(44);
    }];
    [_theThreeBabyNameText mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_theThreeBabyNameLabel.mas_right).with.offset(10) ;
        make.width.equalTo(@150) ;
        make.height.equalTo(@44) ;
        make.top.equalTo(_theThreeBabyLabel.mas_bottom).with.offset(0);
    }];
    [_theThreeDateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_theThreeBabyView.mas_left).with.offset(15) ;
        make.height.equalTo(@44);
        make.top.equalTo(_theThreeBabyView.mas_top).with.offset(88);
    }];
    [_theThreeBabyDateText mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_theThreeDateLabel.mas_right).with.offset(10) ;
        make.right.equalTo(_theThreeBabyView.mas_right) ;
        make.height.equalTo(@44) ;
        make.top.equalTo(_theThreeBabyNameLabel.mas_top).with.offset(44);
    }];
    
    [_jianBtn3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(_theThreeBabyView.mas_right).with.offset(-10) ;
        make.height.equalTo(@33) ;
        make.width.equalTo(@33) ;
        make.centerY.equalTo(_theThreeBabyDateText.mas_centerY);
    }];
}
- (NSDate *)dateFromString:(NSString *)dateString{
    
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    
    [dateFormatter setDateFormat: @"yyyy-MM-dd"];
    
    NSDate *destDate= [dateFormatter dateFromString:dateString];
    
    
    
    return destDate;
    
}
@end
